{#继承自定义模板#}
{% extends 'indexTemplate.html' %}

{#重写模板title#}
{% block title %}机构信息列表 - 慕学在线网{% endblock %}

{#加载静态模板#}
{% load staticfiles %}

{#重写面包屑#}
{% block customBread %}
<section>
<div class="wp">
    <div class="crumbs">
        <ul>
            <li><a href="{% url 'index' %}">首页</a>></li>
            <li><a href="{% url 'courses:coursePage' %}">公开课程</a>></li>
            <li>课程详情</li>
        </ul>
    </div>
</div>
</section>
{% endblock %}

{#重写主体内容#}
{% block content %}
<section>
	<div class="wp">
		<div class="groupPurchase_detail detail">
			<div class="toppro">
				<div class="left">
					<div class="picbox">
						<div class="tb-booth tb-pic">
							<img width="440" height="445" src="{{ MEDIA_URL }}{{ course.images }}" class="jqzoom" />
						</div>
					</div>
					<div class="des">
						<h1 title="{{ course.name }}">{{ course.name }}</h1>
						<span class="key">{{ course.desc }}</span>
						<div class="prize">
							<span class="fl">难度：<i class="key">{{ course.get_degree_display }}</i></span>
							<span class="fr">学习人数：{{ course.students }}</span>
						</div>
						<ul class="parameter">
							<li><span class="pram word3">时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;长：</span><span>{{ course.learnTimes }}</span></li>
                            <li><span class="pram word3">章&nbsp;节&nbsp;数：</span><span> {{ course.getCourseLessons|length }} </span></li>
                            <li><span class="pram word3">课程类别：</span><span title="{{ course.category }}">{{ course.category }}</span></li>
							<li class="piclist">
                                <span class="pram word4">学习用户：</span>
                                {% for courseUser in course.getCourseUsersForFive %}
                                <span class="pic">
                                    <img width="40" height="40" src="{{ MEDIA_URL }}{{ courseUser.user.image }}"/>
                                </span>
                                {% endfor %}
							</li>
						</ul>
						<div class="btns">
							<div class="btn colectgroupbtn" id="jsLeftBtn">
                                {% if hasFavCourse %}已收藏{% else %}收藏{% endif %}
                            </div>
                            <div class="buy btn">
                                <a style="color: white" href="{% url 'courses:courseVideo' course.id %}">开始学习</a>
                            </div>
						</div>
					</div>
                    <div class="group-share-box">
                        <div class="bdsharebuttonbox" data-text="django开始了" data-desc="我在#慕课网#发现了"
                             data-comment="" data-url="/group/groupdetail/15/">
                            <span class="fl">分享到：</span>
                            <a href="#" class="bds_more" data-cmd="more"></a>
                            <a title="分享到QQ空间" href="#" class="bds_qzone" data-cmd="qzone"></a>
                            <a title="分享到新浪微博" href="#" class="bds_tsina" data-cmd="tsina"></a>
                            <a title="分享到腾讯微博" href="#" class="bds_tqq" data-cmd="tqq"></a>
                            <a title="分享到人人网" href="#" class="bds_renren" data-cmd="renren"></a>
                            <a title="分享到微信" href="#" class="bds_weixin" data-cmd="weixin"></a>
                        </div>
                    </div>
				</div>
				<div class="right">
					<div class="head">
						<h1>授课机构</h1>
						<p>世界名校，课程权威</p>
					</div>
					<div class="pic">
                        <a href="{% url 'orgs:orgHome' course.org.id %}">
                            <img width="150" height="80" src="{{ MEDIA_URL }}{{ course.org.image }}"/>
                        </a>
                    </div>
					<a href="{% url 'orgs:orgHome' course.org.id %}">
                        <h2 class="center" title="{{ course.org.name }}">{{ course.org.name }}</h2>
                    </a>
					<div class="btn notlogin"data-favid="14" id="jsRightBtn">
                         {% if hasFavorg %}已收藏{% else %}收藏{% endif %}
                    </div>
					<div class="clear">
						<ul>
                            <li>
                                <span>课 &nbsp;程&nbsp; 数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ course.org.getorgCourse|length }}</span>
                            </li>
                            <li>
                                <span>教 &nbsp;师&nbsp; 数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ course.org.getorgTeacher|length }}</span>
                            </li>
							<li>所在地区：&nbsp;&nbsp;{{ course.org.address }}</li>
							<li>认&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;证&nbsp;:&nbsp;&nbsp;
                                <img title="金牌机构", src="{% static '/images/gold.png' %}"/>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>
<section>
	<div class="wp">
		<div class="list groupPurchase_detail_pro">
			<div class="left layout">
				<div class="head">
					<ul class="tab_header">
						<li class="active">课程详情</li>
					</ul>
				</div>
				<div class="tab_cont tab_cont1">
                    {% autoescape off %}
                    {{ course.detail }}
                    {% endautoescape %}
				</div>
				<div class="tab_cont tab_cont2" >
					<div class="comment">
						<div class="comenlist">
                                1111
	                    </div>
					</div>
				</div>
			</div>
			<div class="right layout">
				<div class="head">相关课程推荐</div>
                <div class="group_recommend">
                {% for courseRelate in coursesRelate %}
                {% if course.id != courseRelate.id %}
                    <dl>
                        <dt>
                            <a target="_blank" href="">
                                <img width="240" height="220" class="scrollLoading" src="{{ MEDIA_URL }}{{ courseRelate.images }}"/>
                            </a>
                        </dt>
                        <dd>
                            <a target="_blank" href=""><h2>{{ courseRelate.name }}</h2></a>
                            <span class="fl">学习时长：<i class="key">{{ courseRelate.learnTimes }}</i></span>
                        </dd>
                    </dl>
                {% endif %}
                {% endfor %}
                </div>
			</div>
		</div>
	</div>
</section>

<script type="text/javascript">
$(function(){
    //收藏课程:3
    $('#jsLeftBtn').on('click',function(){
        add_fav($(this),{{ course.id }},3);
    })
    //收藏机构:1
    $('#jsRightBtn').on('click',function(){
        add_fav($(this),{{ course.org.id }},1);
    })
})
function add_fav(current_elem,favId,favType){
    $.ajax({
        cache: false,
        async: true,
        type: "POST",
        url:"{% url 'operations:userFavorite' %}",
        data:{'favId':favId,'favType':favType},
        beforeSend:function(xhr,settings){
            xhr.setRequestHeader("X-CSRFToken","{{ csrf_token }}");
        },
        success: function(data){
            if(data.status == "success"){
                if(data.msg == "收藏成功"){
                    current_elem.text("取消收藏")
                }else{
                    current_elem.text("收藏")
                }
            }else{
                if(data.msg == "用户未登录"){
                    alert("您还没有登录,请先登录！")
                    window.location.href="{% url 'users:login' %}";
                }else{
                    alert(data.msg)
                }
            }
        }
    })
}
</script>

{% endblock %}


